//
// Created by hugan on 2021/9/13.
//
#ifndef HTTSCPP_SAPIMANAGER_H
#define HTTSCPP_SAPIMANAGER_H

#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }

#include <iostream>
#include <windows.h>
#include <sphelper.h>
#include <string>
#include "SAPITypeDef.cpp"

static bool logDebug = false;

/**
 * https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms723627(v=vs.85)
 */
class SAPIManager {
private:
    //https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms719576(v=vs.85)
    ISpVoice *pVoice = nullptr;
    /**
     * 当前使用的语音引擎
     */
    ISpObjectToken *pSpToken = nullptr;
public:
    SAPIManager();

    ~SAPIManager();

    HRESULT init(bool logDebug);

    void release();

    HRESULT enumVoice(func_enumVoiceCallback callback);

    HRESULT setVoice(int voiceIndex);

    HRESULT setVolume(int volume);

    HRESULT setRate(int rate);

    HRESULT speak(LPCWSTR text);

    HRESULT stop();

    HRESULT pause();

    HRESULT resume();
};

#endif //HTTSCPP_SAPIMANAGER_H
